package leetcode_5000;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class _易混淆数 {
	public static void main(String[] args) {
		_易混淆数 test = new _易混淆数();
		System.out.println(test.confusingNumber(6));
		System.out.println(test.confusingNumber(89));
		System.out.println(test.confusingNumber(11));
		System.out.println(test.confusingNumber(25));
		System.out.println(test.confusingNumber(916));
	}
	public boolean confusingNumber(int N) {
        Map<Integer,Integer> map = new HashMap<Integer,Integer>();
        map.put(1, 1);
        map.put(6, 9);
        map.put(9, 6);
        map.put(0, 0);
        map.put(8, 8);
        List<Integer> list = new ArrayList<Integer>();
        while(N > 0) {	
        	int left = N%10;
        	list.add(left);
        	if(!map.containsKey(left)) return false;
        	N/=10;
        }
        int left =0 ,right =list.size()-1;
        while(left<=right) {
        	int L = list.get(left);
        	if(map.get(L) != list.get(right)) return true;
        	++left;
        	--right;
        }
        return false;
    }
}
